package cn.itcast.erp.controller;

import cn.itcast.erp.annotation.CheckPower;
import cn.itcast.erp.entity.Market;
import cn.itcast.erp.entity.MarketDate;
import cn.itcast.erp.entity.utils.AjaxResult;
import cn.itcast.erp.entity.utils.LogUtils;
import cn.itcast.erp.service.MarketService;
import com.alibaba.fastjson.JSON;
import org.hibernate.annotations.Check;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * MarketService
 * @author 周昌洋
 * @date 2019/6/6
 */

@Controller
public class MarketController {

    @Resource
    private MarketService marketService;


    //销售统计表
    @CheckPower("销售统计表")
    @ResponseBody
    @RequestMapping(value = "/statistics" ,method = {RequestMethod.POST})
    public List<Map<String,Object>> typeMarket(@Validated Market market){

        List<Map<String,Object>> markets = this.marketService.typeMarket(market);

        return markets ;
    }

    //查询销售趋势图年份
    @CheckPower("销售趋势分析")
    @ResponseBody
    @RequestMapping(value = "/year", method = {RequestMethod.POST})
    public List<Map> yearMarket(){

        List<Map> list = this.marketService.yearMarket();
        return list;
    }

    //销售趋势表
    @CheckPower("销售趋势分析")
    @RequestMapping(value = "/trend",method = {RequestMethod.POST})
    @ResponseBody
    public List<Map<String,Object>> monthMarket(@Validated Market market){

        List<Map<String,Object>> list = this.marketService.monthMaket(market);

        return list;

    }




}
